package com.servlet;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.User;
import com.serveImple.UpdateUserImple;

/**
 * Servlet implementation class UpdateUserServlet
 */
@WebServlet("/UpdateUserServlet")
public class UpdateUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public UpdateUserServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String name=request.getParameter("uname");
		String truename=request.getParameter("truename");
		String password=request.getParameter("psw");
		String address=request.getParameter("address");
		String phone=request.getParameter("phone");
		String sex=request.getParameter("sex");
		String birth=request.getParameter("birth");
		UpdateUserImple uui=new UpdateUserImple();
		User user= new User();
		user.setU_address(address);
		user.setU_password(password);
		user.setU_name(name);
		user.setU_phone(phone);
		user.setU_sex(sex);
		user.setU_truename(truename);
		user.setU_birth(new Date(birth));
		User user1=uui.updateUser(user);
		request.setAttribute("user1", user1);
		request.getRequestDispatcher("UpdateUser.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
